<%@ page language="java" contentType="text/html; charset=ISO-8859-1"  pageEncoding="ISO-8859-1"%>
<%@page import="dto.UserDTO"%>
<%@ page import= "java.util.Iterator"%>
<%@ page import= "java.util.List"%>

<!DOCTYPE html>
<html lang="en">

<head>
	<title>Lista de Usuarios</title>
	
	 <script type="text/javascript" src="js/jquery-1.8.2.js"></script>
</head>
<body>

        <div class="box">
                    <table class="ink-table">
                        <thead>
                            <tr>
									<th colspan="4" style="background-color: #1C70C2; color:white;"><b>Lista de Usuarios</b></th>
							</tr>
							<tr>
									<th><b>Id</b></th>
									<th><b>Nombre</b></th>
									<th><b>Password</b></th>
									<th><b>Estado</b></th>

									
							</tr>
                        </thead>
                                
                        <tbody>
                          <%
								UserDTO aux;
								Integer id; 	
								List<UserDTO>  usuarios = (List<UserDTO>)request.getAttribute("usuarios");
								for(Iterator<UserDTO> i = usuarios.iterator(); i.hasNext();)
								{
									aux = i.next();
									id = aux.getId();
							%>
								<tr>
								
									<td><%=aux.getId()%></td>	
							 		<td><%=aux.getUsername()%></td>
									<td><%=aux.getPassword()%></td>
									<td><a onclick="cambiarEstado(<%=id%>)"><%=aux.getEstado()%></a></td>
								
									
									
								</tr>
							<% } %>
								<tr>
									<td colspan="4">
									 <a class="registrarUsuario">Registrar Usuario</a>
									</td>
								</tr>
                        </tbody>
                    </table>
        </div>
<script>


function cambiarEstado(id){
	$( ".htmlContent" ).load( "ControladorUser?action=cambioestado&id="+id).hide().fadeIn('slow');

}

$( ".registrarUsuario" ).click(function() {

	$( ".htmlContent" ).load( "ControladorUser?action=new").hide().fadeIn('slow');
});


</script>
</body>
</html>